import "./scss/svgIcon.scss"

const requireAll = (requireContext) => {
    return requireContext.keys().map(requireContext)
}
// require.context(要搜索的文件夹目录, 是否还应该搜索它的子目录, 匹配文件的正则表达式)
const req = require.context("../assets/svg", true, /.svg$/)
requireAll(req)

const style = {
    width: 20,
    height: 20,
    color: "currentColor",
}

const Icon = (props) => {
    let { name, width, height, color, className } = props
    const styleOptions = {
        ...style,
        width,
        height,
        color,
    }
    return (
        <svg className={`svg_icon ${className ? className : ""}`} style={styleOptions}>
            <use xlinkHref={`#${name}`} />
        </svg>
    )
}
export default Icon
